function ModelCreator(Model) {
  class ExtendModel extends Model {
    constructor(...args) {
      super(...args)
    }

    // todo check
    async onchange(ids, values, fname, field_onchange, kwargs = {}) {
      // 对 odoo model 的 简单扩展
      // 如果 context 中有 default_is_internal_transfer 且是 default_get
      // 需要后续跟一个 is_internal_transfer 字段的 onchange
      //

      const { context = {} } = kwargs
      const { default_is_internal_transfer } = context
      const res = await super.onchange(
        ids,
        values,
        fname,
        field_onchange,
        kwargs
      )

      const for_new_internal_transfer =
        default_is_internal_transfer && Array.isArray(fname) && !fname.length

      if (!for_new_internal_transfer) return res

      console.log('todo: account.payment onchange for_new_internal_transfer')

      return res

      // const { value } = res

      // const values_onchange = this._format_to_onchange(value)
      // const values_onchange2 = {
      //   ...values_onchange,
      //   is_internal_transfer: true
      // }
      // const res2 = await super.onchange(
      //   ids,
      //   values_onchange2,
      //   'is_internal_transfer',
      //   field_onchange,
      //   kwargs
      // )

      // const { value: value2 } = res2

      // const value_return = { ...value, is_internal_transfer: true, ...value2 }

      // return { ...res, ...res2, value: value_return }
    }
  }

  return ExtendModel
}

const metadata = {}

const AddonsModels = {
  'account.payment': { ModelCreator, metadata }
}

export default AddonsModels
